/**
	*****************************************************************************
	* @file     cmem7_dma.h
	*
	* @brief    CMEM7 DMA header file
	*
	*
	* @version  V1.0
	* @date     3. September 2013
	*
	* @note               
	*           
	*****************************************************************************
	* @attention
	*
	* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
	* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
	* TIME. AS A RESULT, CAPITAL-MICRO SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 
	* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
	* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
	* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
	*
	* <h2><center>&copy; COPYRIGHT 2013 Capital-micro </center></h2>
	*****************************************************************************
	*/
	
#ifndef __CMEM7_DMA_H
#define __CMEM7_DMA_H

#ifdef __cplusplus
 extern "C" {
#endif

#include "cmem7.h"
#include "cmem7_conf.h"

#define DMA_Int_TfrComplete                0x00000001    
#define DMA_Int_Err                        0x00000002
#define DMA_Int_All                        0x00000003

#define IS_DMA_INT(INT)        (((INT) & ~DMA_Int_All) == 0)


/**
  * @}
  */ 

typedef struct {                      
	uint32_t srcAddr;                  /*!< source address in memory */		
	uint32_t dstAddr;                  /*!< destination address in memory */	
	uint32_t number;                   /*!< block byte number, no more than 2K Bytes */
	uint32_t nextBlock;                /*!< next block descriptor */
	uint32_t padding;                  /*!< used to fill */
} BLOCK_DESC;
	
void DMA_Init(void);
void DMA_EnableInt(uint32_t Int, BOOL enable);
BOOL DMA_GetIntStatus(uint32_t Int);
void DMA_ClearInt(uint32_t Int);
/* blockList should be allocated in physical memory and deleted after DMA complete */
BOOL DMA_Transfer(BLOCK_DESC *blockList);
BOOL DMA_IsBusy(void);

#ifdef __cplusplus
}
#endif

#endif /* __CMEM7_DMA_H */

